// https://www.lintcode.com/problem/string-permutation/description?_from=ladder&&fromId=6

class Solution {
public:
    /**
     * @param A: a string
     * @param B: a string
     * @return: a boolean
     */
    bool Permutation(string &A, string &B) {
        // sort(A.begin(), A.end());
        // sort(B.begin(), B.end());
        // return A == B;
        
        
        // int record[256] = {0};
        int record[256];
        memset(record, 0, sizeof(record));
        for (int i = 0; i < A.length(); ++i)
        {
            record[A[i]]++;
        }
        for (int i = 0; i < B.length(); ++i)
        {
            record[B[i]]--;
        }
        for (int i = 0; i < 256; ++i)
        {
            if (record[i] != 0)
            {
                return false;
            }
        }
        return true;
    }
};